﻿@namespace MudBlazor.Docs.Examples

<MudDialog>
    <DialogContent>
        <div class="d-flex flex-column py-1">
            <MudButton OnClick="ChangeTitleAsync">Change Title</MudButton>
            <MudButton OnClick="ToggleCloseButtonAsync">Toggle Close Button</MudButton>
            <MudButton OnClick="ToggleFullWidthAsync">Toggle Full Width</MudButton>
            <MudButton OnClick="ToggleHeaderAsync">Toggle Header</MudButton>
        </div>
    </DialogContent>
    <DialogActions>
        <MudButton Color="Color.Primary" OnClick="Close">OK</MudButton>
    </DialogActions>
</MudDialog>

@code {
    [CascadingParameter]
    private IMudDialogInstance MudDialog { get; set; }

    private void Close() => MudDialog.Close(DialogResult.Ok(true));

    private Task ChangeTitleAsync() => MudDialog.SetTitleAsync($"Current time is: {DateTime.Now}");

    private Task ToggleCloseButtonAsync()
    {
        var options = MudDialog.Options with
        {
            CloseButton = !(MudDialog.Options.CloseButton ?? false)
        };

        return MudDialog.SetOptionsAsync(options);
    }

    private Task ToggleFullWidthAsync()
    {
        var options = MudDialog.Options with
        {
            FullWidth = !(MudDialog.Options.FullWidth ?? true)
        };

        return MudDialog.SetOptionsAsync(options);
    }

    private Task ToggleHeaderAsync()
    {
        var options = MudDialog.Options with
        {
            NoHeader = !(MudDialog.Options.NoHeader ?? false)
        };

        return MudDialog.SetOptionsAsync(options);
    }
}
